package person.bing.fbcloud.leetcode;

import java.util.Arrays;

/**
 * @author: mengfanbing
 * @date: 2020/12/15 9:47
 */
public class Q34 {
    public static void main(String[] args) {
        int[] nums = {5,7,7,8,8,10};
        int target = 6;
        System.out.println(Arrays.toString(searchRange(nums,target)));
    }

    public static int[] searchRange(int[] nums, int target) {
        int[] ans = {-1,-1};
        int length = nums.length;
        for (int i=0;i<length;i++){
            if (nums[i] == target){
                ans[0] = i;
                break;
            }
        }
        for (int i=length-1;i>=0;i--){
            if (nums[i] == target){
                ans[1] = i;
                break;
            }
        }
        return ans;
    }
}
